﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Twitterizer;

namespace TwitterTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var searchList = new List<string> { "joe satriani", "steve vai", "paul gilbert", "john petrucci", "eric johnson" };
            var search = TwitterSearch.Search(searchList[new Random().Next(0, searchList.Count)]);

            TestWebClient();

            Console.ReadLine();



            //OAuthTokens tokensAsy1um1 = new OAuthTokens
            //{
            //    ConsumerKey = "XC2QOnWrLeyLLaMzTremeA",
            //    ConsumerSecret = "Di0VsISUcsOmoUvABaySHdwqyiC6zdfz4mGoeSQbQ",
            //    AccessToken = "826740630-tYmlaYYsss0WOSrKokb0jiwMoiegBuz85djZ50DO",
            //    AccessTokenSecret = "fbAk64eHbXdvKBesuPJ7rUHaFQjKUT3mi8mYDqMEnDI"
            //};

            OAuthTokens tokensUsertest_3000 = new OAuthTokens
            {
                ConsumerKey = "wQQXWuOwxsWhlAbTl27Ew",
                ConsumerSecret = "JhmfDUI20b9pq3x149QqhEiILqLggeJaQ7Cp7h1Z4",
                AccessToken = "826895832-gZ38r0D6mxZDKtPFOUBIUl36xdVrdsiiCHCjeKft",
                AccessTokenSecret = "Zlt32cJmETpePWA2Nw9eEUcjoBWN8OQXMeZ3FDP6U"
            };

            OAuthTokens tokensUsertest_3001 = new OAuthTokens
            {
                ConsumerKey = "Yc4qYJm3yTEf56HCJs1QVw",
                ConsumerSecret = "mWAmtVRri35VumsUEv0Wlz63IfSmjQU3Uo12EEk",
                AccessToken = "826916017-izbVCjmNIIDJo3saAnnE3RqnsyTZGN6NNHP1NYlp",
                AccessTokenSecret = "IbsBzJaB9iMXbJacfCDTKpx7G7kFTCJ15EzViEODrc"
            };
            

            for (int i = 1; i < Int32.MaxValue; i++)
            {
                SendMessage(tokensUsertest_3000, i);
                SendMessage(tokensUsertest_3001, i);
                //var search = TwitterSearch.Search(searchList[new Random().Next(0, searchList.Count)]);
                //if (search.Result != RequestResult.Success)
                //{
                //    Console.WriteLine("Error after {0} iterations. Error message: {1}", i, search.ErrorMessage);
                //    break;
                //}
                Thread.Sleep(1000);

            }

            Console.ReadLine();
        }

        private static void SendMessage(OAuthTokens token, int i)
        {
            string message = string.Format("message from app 1 {0}", i);
            TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(token, message);
            if (tweetResponse.Result != RequestResult.Success)
            {
                Console.WriteLine("Error after {0} iterations. Error message: {1}", i, tweetResponse.ErrorMessage);
            }
        }

        private static void TestWebClient()
        {
            var client = new WebClient();
            //client.Proxy = new WebProxy("95.159.31.31:80");
            var result = client.DownloadString("http://yandex.ru");
        }
    }
}
